package com.eece496.Database;

import java.sql.SQLException;
import java.sql.Statement;

public class TASaveData extends Database {

	private int TAID;
	private String COGSName;
	private int id =0;
	private int grade;
	private String courseNumber = null;
	private String sectionNumber = null;
	
	public TASaveData()
	{
		tableName="TASaveData";
	}
	
	public TASaveData(int TAID, String COGSName, int grade, String courseNumber, String sectionNumber)
	{
		tableName = "TASaveData";
		
		this.TAID = TAID;
		this.COGSName = COGSName;
		this.grade = grade;
		this.courseNumber = courseNumber;
		this.sectionNumber = sectionNumber;
		
	}
	@Override
	public void Insert() throws SQLException {

		Statement stmt = connection.createStatement();
		
		String sqlString = "INSERT INTO " + tableName + " VALUES (" + id + ", " +
				TAID + ", " +			
				AddQuotes(COGSName) + ", " + grade + ", " + AddQuotes(courseNumber) + ", " + AddQuotes(sectionNumber) + 
				")";
		
	    stmt.executeUpdate(sqlString);
	    System.out.println(sqlString);

	}

	public void DeleteCourseSaveData(String courseNumber, String sectionNumber) throws SQLException
	{
		Statement stmt = connection.createStatement();
		
		String sqlString = "DELETE from " + tableName + " WHERE courseNumber = " + AddQuotes(courseNumber) +
				" and sectionNumber= " + AddQuotes(sectionNumber);
		
		stmt.executeUpdate(sqlString);
		
	}
	
	public void DeleteTAData(int tID, String courseNumber, String sectionNumber) throws SQLException
	{
		Statement stmt = connection.createStatement();
		
		String sqlString = "DELETE from " + tableName + " WHERE courseNumber = " + AddQuotes(courseNumber) +
				" and sectionNumber= " + AddQuotes(sectionNumber) + " and TAID = " + tID;
		
		stmt.executeUpdate(sqlString);
	}
	
	@Override
	public void Delete(String primaryKey) throws SQLException {
		// TODO Auto-generated method stub

	}

	@Override
	public void Display() throws SQLException {
		// TODO Auto-generated method stub

	}
}